package com.java.star.mall.front.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.java.star.mall.common.response.JsonResult;
import com.java.star.mall.front.pojo.vo.CategoryProductVO;
import com.java.star.mall.front.pojo.vo.CategoryVO;
import com.java.star.mall.front.service.CategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 商品分类Controller
 */
@Api(value = "product", tags = "商品分类")
@RestController
@RequestMapping("/category")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    @ApiOperation("查询首页分类列表")
    @ApiOperationSupport(order = 100)
    @GetMapping("/listIndexCategory")
    public JsonResult<List<CategoryVO>> listIndexCategory() {
        List<CategoryVO> indexCategory = categoryService.listIndexCategory();
        return JsonResult.ok(indexCategory);
    }

    @ApiOperation("查询分类及分类商品列表")
    @ApiOperationSupport(order = 200)
    @GetMapping("/listCategoryProduct")
    public JsonResult<List<CategoryProductVO>> listCategoryProduct() {
        List<CategoryProductVO> categoryProductVOList = categoryService.listCategoryProduct();
        return JsonResult.ok(categoryProductVOList);
    }
}
